FROM mysql:8.0.27

#使得debian系统支持ps命令
RUN  apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C

RUN  apt-get update &&  apt-get install -y procps

 # init app db
COPY app/initSql/data /opt/sql/
COPY app/initSql/init.sql /docker-entrypoint-initdb.d/

# Config files
COPY config/ /etc/mysql/
#COPY docker-entrypoint.sh /usr/local/bin/
#RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat

RUN chmod 644 /etc/mysql/my.cnf


WORKDIR /opt/java

# install jdk
COPY jdk/jdk-8u202-linux-x64.tar.gz /opt/java
RUN tar -xzf /opt/java/jdk-8u202-linux-x64.tar.gz -C /opt/java
RUN rm /opt/java/jdk-8u202-linux-x64.tar.gz

ENV JAVA_HOME /opt/java/jdk1.8.0_202
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH $PATH:$JAVA_HOME/bin


# install app
# RUN命令执行创建用户和用户组（命令创建了一个用户newuser设定ID为5000，并指定了用户登录后使用的主目录和shell）
#RUN groupadd --gid 5000 ac \
# && useradd --home-dir /home/ac/Release --create-home --uid 5000 --gid 5000 --shell /bin/bash --skel /dev/null ac

# RUN   ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

# nginx所需包
ADD --chown=root:root libssl /lib/x86_64-linux-gnu

WORKDIR /lib/x86_64-linux-gnu/
RUN ln -s libpcre.so.3 libpcre.so.1
RUN ln -s libssl.so.1.0.2k libssl.so.10
RUN ln -s libcrypto.so.1.0.2k libcrypto.so.10


#USER ac

#工作目录
WORKDIR /home/ac/Release

# 设定时区
ENV TIME_ZONE=Asia/Shanghai
RUN cp /usr/share/zoneinfo/$TIME_ZONE /etc/localtime

#导入编译后的jar包
COPY  app/bin /home/ac/Release/bin/
COPY   app/config/ /home/ac/Release/config/
COPY   app/fastjar/ /home/ac/Release/fastjar/
COPY   app/fastjar-enc/ /home/ac/Release/fastjar-enc/
COPY   app/lib/ /home/ac/Release/lib/
COPY   app/logs/ /home/ac/Release/logs/
COPY   app/temp/ /home/ac/Release/temp/
COPY  app/html/ /home/ac/Release/html/

# app日志目录
RUN mkdir -p /home/mysql/logs/consolelogs
RUN mkdir -p /home/ac/Release/logs/consolelogs
RUN mkdir -p /home/ac/Release/logs/rocketmqlogs
RUN mkdir -p /home/ac/Release/logs/ac/point
RUN mkdir -p /home/ac/Release/logs/ac/audit
RUN mkdir -p /home/ac/Release/data
RUN mkdir -p /home/ac/Release/store

RUN chmod -R 777 /home/ac/Release/logs
RUN chmod -R 777 /home/ac/Release/data
RUN chmod -R 777 /home/ac/Release/store
RUN chmod -R 777 /home/ac/Release/temp

RUN chmod +x /home/ac/Release/bin/*.sh
RUN chmod +x /home/ac/Release/bin/nginx
RUN chmod +x /home/ac/Release/fastjar/ac-boot.jar
RUN chmod +x /home/ac/Release/fastjar-enc/ac-agent-1.0.jar
RUN chmod +x /home/ac/Release/lib/redis/linux/*

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh


#暴露端口
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 3306 33060 9199 8000
CMD ["mysqld"]


